package com.whjfxx.terminal.base;

import com.alibaba.fastjson.JSONObject;
import com.whjfxx.terminal.commons.Base64Util;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by b.c on 2022/4/27 16:27
 */
@RestController
public class ApiBaseController {

    @Autowired
    HttpServletRequest httpServletRequest;

    protected String encode(String data) {
        String jsonStr = Base64Util.decodeToString(data);
        return jsonStr;
    }

    protected<T> T encodeTeBean(String data, Class<T> clazz) {
        String paramJsonStr = Base64Util.decodeToString(data);
        // json转换成对象
        T obj = JSONObject.parseObject(paramJsonStr, clazz);
        return obj;
    }

}
